<html>
<head>
<style>
body {width:350px; white-space:nowrap}
</style>
<script>

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-22179584-1']);
_gaq.push(['_trackPageview','extension/cookie-cleaner/popup.html']);

</script>
<script src="ga.js"></script>
<script>
/*
    http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
 @author     Richard Wagener <code@securebucket.com>
*/
if(!chrome.cookies) {
  chrome.cookies = chrome.experimental.cookies
}
function trackAction(h,c) {
        _gaq.push(['_trackEvent', 'Chrome Cookie Cleaner', 'Cookies Removed', h, c ]);
}
function Timer() {
  this.start_ = new Date;
  this.elapsed = function() {
    return new Date - this.start_
  };
  this.reset = function() {
    this.start_ = new Date
  }
}
function cookieMatch(a, b) {
  return a.name == b.name && a.domain == b.domain && a.hostOnly == b.hostOnly && a.path == b.path && a.secure == b.secure && a.httpOnly == b.httpOnly && a.session == b.session && a.storeId == b.storeId
}
function sortedKeys(a) {
  var b = [], d;
  for(d in a) {
    b.push(d)
  }
  b.sort();
  return b
}
function select(a) {
  return document.querySelector(a)
}
function CookieCache() {
  this.cookies_ = {};
  this.reset = function() {
    this.cookies_ = {}
  };
  this.add = function(a) {
    var b = a.domain;
    this.cookies_[b] || (this.cookies_[b] = []);
    this.cookies_[b].push(a)
  };
  this.remove = function(a) {
    var b = a.domain;
    if(this.cookies_[b]) {
      for(var d = 0;d < this.cookies_[b].length;) {
        cookieMatch(this.cookies_[b][d], a) ? this.cookies_[b].splice(d, 1) : d++
      }
      this.cookies_[b].length == 0 && delete this.cookies_[b]
    }
  };
  this.getDomains = function(a) {
    var b = [];
    sortedKeys(this.cookies_).forEach(function(d) {
      (!a || d.indexOf(a) != -1) && b.push(d)
    });
    return b
  };
  this.getCookies = function(a) {
    return this.cookies_[a]
  }
}
function removeAllForFilter(a) {
  new Timer;
  var b = 0;
  cache.getDomains(a).forEach(function(a) {
    removeCookiesForDomain(a)
  });
  cache.getDomains(a).forEach(function(a) {
    b += removeCookiesForDomain(a)
  });
  return b
}
function removeCookie(a) {
  chrome.cookies.remove({url:"http" + (a.secure ? "s" : "") + "://" + a.domain + a.path, name:a.name})
}
function removeCookiesForDomain(a) {
  new Timer;
  var b = 0;
  cache.getCookies(a).forEach(function(a) {
    removeCookie(a);
    b++
  });
  return b
}
var cache = new CookieCache;
try {
  localStorage.open_tab = localStorage.open_tab == void 0 ? "no" : localStorage.open_tab == "yes" ? "yes" : "no", chrome.tabs.getSelected(null, function(a) {
    var b = a.url, d = a.id, c = parseUri(a.url).host;
    c.substr(0, 4) == "www." && (c = c.substr(4));
    a = c.split(".").length - 1;
    c.substr(-2) == "uk" ? a > 2 && (c = stristr(c, ".")) : a > 1 && (c = stristr(c, "."));
    c.substr(0, 1) == "." && (c = c.substr(1));
    var f = new Timer;
    chrome.cookies.getAll({}, function(a) {
      start = new Date;
      for(var e in a) {
        cache.add(a[e])
      }
      f.reset();
      if(cache.getDomains(c).length > "0") {
        if(temp = removeAllForFilter(c)) {
          localStorage.cookiesRemoved = temp, localStorage.hostRemoved = c, trackAction(c,temp), chrome.extension.sendRequest({durationSecs:60}), document.getElementById("content").innerHTML = "Working", chrome.tabs.remove(d), localStorage.open_tab == "yes" && chrome.tabs.create({url:b})
        }
      }else {
        document.getElementById("content").innerHTML = "Nothing to remove."
      }
    })
  })
}catch(e$$5) {
  document.getElementById("content").innerHTML = "Error: " + e$$5
}
function stristr(a, b, d) {
  var c = 0;
  a += "";
  c = a.toLowerCase().indexOf((b + "").toLowerCase());
  return c == -1 ? !1 : d ? a.substr(0, c) : a.slice(c)
}
function parseUri(a) {
  for(var b = parseUri.options, a = b.parser[b.strictMode ? "strict" : "loose"].exec(a), d = {}, c = 14;c--;) {
    d[b.key[c]] = a[c] || ""
  }
  d[b.q.name] = {};
  d[b.key[12]].replace(b.q.parser, function(a, c, e) {
    c && (d[b.q.name][c] = e)
  });
  return d
}
parseUri.options = {strictMode:!1, key:["source", "protocol", "authority", "userInfo", "user", "password", "host", "port", "relative", "path", "directory", "file", "query", "anchor"], q:{name:"queryKey", parser:/(?:^|&)([^&=]*)=?([^&]*)/g}, parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}};
</script>
</head>
<body>
<div id="content"></div>
</body>
</html>